package jp.seraph.same.view;

import java.awt.Component;
import java.awt.Container;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JPanel;

import org.apache.commons.lang.NotImplementedException;

import jp.seraph.same.controller.PoseController;
import jp.seraph.same.model.JointModel;
import jp.seraph.same.model.PoseModel;

/**
 * 縦1列のジョイントを示すコンポーネントを格納するパネルです
 * 
 * 
 */
public class JointListPanel extends JPanel {
    public JointListPanel(Container aParent, PoseModel aModel, PoseController aController) {
        mModels = new ArrayList<JointModel>();
        mParent = aParent;
        // mModel = aModel;
        mController = aController;
    }

    public void addJoint(JointModel aModel) {
        int tLength = mModels.size();
        for (int i = 0; i < tLength; i++) {
            JointModel tModel = mModels.get(i);
            if (tModel.getJointOrder() > aModel.getJointOrder()) {
                mModels.add(i, aModel);
                super.add(JointRadioButton.create(mParent, aModel, mController), i);
                return;
            }
        }
        mModels.add(tLength, aModel);
        super.add(JointRadioButton.create(mParent, aModel, mController), tLength);
    }

    private List<JointModel> mModels;
    private Container mParent;
    // private PoseModel mModel;
    private PoseController mController;
    private static final long serialVersionUID = 10L;

    public void setModel(PoseModel aModel) {
        // mModel = aModel;
    }

    /**
     * 
     * @see java.awt.Container#add(java.awt.Component, int)
     */

    public Component add(Component aComponent1, int aI) {
        throw new NotImplementedException("このクラスはこのメソッドをサポートしません");
    }

    /**
     * 
     * @see java.awt.Container#add(java.awt.Component, java.lang.Object, int)
     */

    public void add(Component aComponent1, Object aObj, int aI) {
        throw new NotImplementedException("このクラスはこのメソッドをサポートしません");
    }

    /**
     * 
     * @see java.awt.Container#add(java.awt.Component, java.lang.Object)
     */

    public void add(Component aComponent1, Object aObj) {
        throw new NotImplementedException("このクラスはこのメソッドをサポートしません");
    }

    /**
     * 
     * @see java.awt.Container#add(java.awt.Component)
     */

    public Component add(Component aComponent1) {
        throw new NotImplementedException("このクラスはこのメソッドをサポートしません");
    }

    /**
     * 
     * @see java.awt.Container#add(java.lang.String, java.awt.Component)
     */

    public Component add(String aS, Component aComponent1) {
        throw new NotImplementedException("このクラスはこのメソッドをサポートしません");
    }

    /**
     * 
     * @see java.awt.Container#remove(java.awt.Component)
     */

    public void remove(Component aComponent1) {
        throw new NotImplementedException("このクラスはこのメソッドをサポートしません");
    }

    /**
     * 
     * @see java.awt.Container#remove(int)
     */

    public void remove(int aI) {
        mModels.remove(aI);
        super.remove(aI);
    }

    /**
     * 
     * @see java.awt.Container#removeAll()
     */

    public void removeAll() {
        mModels.clear();
        super.removeAll();
    }

}
